import myAxios from "@/request/myAxios";

// 添加帖子
export const setAddBlog = (formData:FormData) => {
  return myAxios.post('/blog/add',formData,{
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
} 

// 获取帖子
export const getBlogList = (currentPage:number,title:string) => {
  return myAxios.get('/blog/list',{
    params:{
      currentPage,
      title
    }
  })
}

// 点赞帖子
export const getBlogLike = (id:string) => {
  return myAxios.put('/blog/like/' + id)
}

//　获取帖子详情
export const getBlogDetailInfo = (id:string) => {
  return myAxios.get('/blog/'+id)
}

// 获取帖子评论
export const getComments = (id: string) => {
  return myAxios.get('/comments',{
    params: {
      blogId: id
    }
  })
}

// 点赞评论
export const getCommentsLike = (id:string) => {
  return myAxios.put('/comments/like/'+id)
}

// 获取单个评论的信息
export const getComment = (id:string) => {
  return myAxios.get('/comments/'+id)
}

// 删除评论
export const getDelComment = (id:string) => {
  return myAxios.delete('/comments/' + id)
}

// 发评论
export const getPostComment = (blogId:string,content:string) => {
  return myAxios.post('/comments/add',{
    blogId,
    content
  })
}

// 删除帖子
export const getDelBlog = (id:string) => {
  return myAxios.delete("/blog/" +id);
}
// 更新帖子
export const getEditBlog = (formData: FormData) => {
  return myAxios.put("/blog/update", formData, {
            headers: {
                "Content-Type": "multipart/form-data"
            }
          })
}